using System;
using System.Collections.Generic;
using Dict.DataModel;

namespace Dict.Dao
{
    public class TableUnionFightTowerDao:DaoBase<TableUnionFightTower>
    {
        public override void AddPrimaryIndex(TableUnionFightTower model)
        {
            cachePrimary[model.UFTId.ToString()] = model;
        }

        public override string GetFileName()
        {
            return "TableUnionFightTower.txt";
        }

        protected override TableUnionFightTower ParseRowData(string[] rowData)
        {
            TableUnionFightTower data = new TableUnionFightTower();

            if (string.IsNullOrEmpty(rowData[0]))
            {
                data.UFTId = 0;
            }
            else
            {
                data.UFTId = int.Parse(rowData[0]);
            }

            if (string.IsNullOrEmpty(rowData[1]))
            {
                data.UFId = 0;
            }
            else
            {
                data.UFId = int.Parse(rowData[1]);
            }
			data.Position = rowData [2];

            if (string.IsNullOrEmpty(rowData[3]))
            {
                data.Height = 0;
            }
            else
            {
                data.Height = double.Parse(rowData[3]);
            }
			data.Name = rowData [4];

            if (string.IsNullOrEmpty(rowData[5]))
            {
                data.Camp = 0;
            }
            else
            {
                data.Camp = int.Parse(rowData[5]);
            }

            if (string.IsNullOrEmpty(rowData[6]))
            {
                data.Range = 0;
            }
            else
            {
                data.Range = double.Parse(rowData[6]);
            }

            if (string.IsNullOrEmpty(rowData[7]))
            {
                data.AttackRange = 0;
            }
            else
            {
                data.AttackRange = double.Parse(rowData[7]);
            }

            if (string.IsNullOrEmpty(rowData[8]))
            {
                data.AttackCountDown = 0;
            }
            else
            {
                data.AttackCountDown = double.Parse(rowData[8]);
            }

            if (string.IsNullOrEmpty(rowData[9]))
            {
                data.AttackDuration = 0;
            }
            else
            {
                data.AttackDuration = double.Parse(rowData[9]);
            }

            if (string.IsNullOrEmpty(rowData[10]))
            {
                data.AttackRelease = 0;
            }
            else
            {
                data.AttackRelease = double.Parse(rowData[10]);
            }

            if (string.IsNullOrEmpty(rowData[11]))
            {
                data.RecoveryTime = 0;
            }
            else
            {
                data.RecoveryTime = double.Parse(rowData[11]);
            }
			data.UFGuardId = rowData [12];
			data.ModelUrl = rowData [13];
			data.FirePoint = rowData [14];
			data.Projectile = rowData [15];
			data.FireEffect = rowData [16];

            return data;
        }


        public override void AddOneIndex(TableUnionFightTower model)
        {
            if (!cacheOneIndex.ContainsKey(model.UFId.ToString()))
            {
                cacheOneIndex[model.UFId.ToString()] = new List<TableUnionFightTower>();
            }
            cacheOneIndex[model.UFId.ToString()].Add(model);
        }
    

    }

}
